<template>
  <div>
    <!--防止生成代码时生成不必要的dropdown的代码-->
    <a-dropdown v-if="isEdit" :trigger="['contextmenu']" @open-change="emit('openChange')">
      <slot></slot>
      <template #overlay>
        <a-menu>
          <a-menu-item key="delete" @click="emit('onDelete')">
            <span class="text-red">删除</span>
          </a-menu-item>
          <a-menu-item key="copy" @click="emit('onCopy')">复制</a-menu-item>
        </a-menu>
      </template>
    </a-dropdown>
    <div v-else>
      <slot></slot>
    </div>
  </div>
</template>

<script setup lang="ts">
defineProps({
  isEdit: Boolean
})
const emit = defineEmits(['openChange', 'onDelete', 'onCopy'])
</script>

<style scoped></style>
